home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / System / PPCReleaseDEV / Examples / callosasync.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-21  |  1.7 KB  |  64 lines

  1. #include <exec/types.h>
  2. #include <exec/nodes.h>
  3. #include <exec/lists.h>
  4. #include <exec/memory.h>
  5. #include <powerup/ppclib/interface.h>
  6. #include <powerup/gcclib/powerup_protos.h>
  7. #include <powerup/ppcinline/exec.h>
  8.  
  9. #define    LOOP    10
  10.  
  11. char    Buffer[LOOP][256];
  12.  
  13. /* Attention
  14.  * You can share the Caos structure for asynchronus calls because
  15.  * it`s copied to some internal buffer BUT you must be careful about
  16.  * the data itself which is used. 
  17.  * In this case Buffer is the problem so you have to work around this
  18.  * and do some asynchron buffer management.
  19.  */
  20.  
  21. int Function(APTR    Function)
  22. {
  23. BPTR        MyFile;
  24. struct Caos    *MyCaos;
  25. ULONG        DataArray[1];
  26. ULONG        i;
  27. void        *DOSBase;
  28. void        *SysBase;
  29.  
  30.   if (MyFile=PPCOpen("con:0/0/640/200/CallOSASync/CLOSE/AUTO/WAIT",MODE_NEWFILE))
  31.   {
  32.     if (MyCaos = (struct Caos*) PPCAllocVec(sizeof(struct Caos),MEMF_PUBLIC|MEMF_CLEAR))
  33.     {
  34.       SysBase    =(void*)    *((ULONG*) 4L);
  35.       if (DOSBase=(void*) OpenLibrary("dos.library",0))
  36.       {
  37.         for (i=0;i<LOOP;i++)
  38.         {
  39.           DataArray[0]    =    i;
  40.  
  41.           PPCRawDoFmt("Asynchron String %ld\n",
  42.                       &DataArray,
  43.                       0,                /* 0=Buffer,1=serial <> NOT supported yet */
  44.                       Buffer[i]);
  45.  
  46.  
  47.           MyCaos->caos_Un.Offset    =    -0x30;
  48.           MyCaos->d1            =    (ULONG) MyFile;
  49.           MyCaos->d2            =    (ULONG) Buffer[i];
  50.           MyCaos->d3            =    strlen(Buffer[i]);
  51.           MyCaos->a6            =    (ULONG) DOSBase;
  52.           MyCaos->M68kCacheMode        =    IF_CACHEFLUSHALL|IF_ASYNC;
  53.           MyCaos->PPCCacheMode        =    IF_CACHEFLUSHALL;
  54.           PPCCallOS(MyCaos);
  55.         }
  56.       }
  57.       PPCFreeVec(MyCaos);
  58.     }
  59.     PPCClose(MyFile);
  60.     return(1);
  61.   }
  62.   return(0);
  63. }
  64.